package db;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AttributeValueEntity extends Entity {

	private String _tblName, _tblColPrefix;

	AttributeValueEntity(String tblName, String tblColPrefix) {
		super();
		this._tblName = tblName;
		this._tblColPrefix = tblColPrefix;
	}

	AttributeValueEntity() {
		super();
	}

	public String _foreinId;

	public String get_foreinId() {
		return _foreinId;
	}

	public String get_value() {
		return _value;
	}

	private String _value;

	@Override
	protected Entity mapToObj(ResultSet rs) {
		AttributeValueEntity ie = new AttributeValueEntity();
		try {
			ie._id = rs.getInt("att_id");
			ie._value = rs.getString(_tblColPrefix + "_value");
			ie._foreinId = rs.getString(_tblColPrefix + "_id");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return ie;
	}

	@Override
	protected void fillPreparedParams(PreparedStatement ps) {
		try {
			ps.setObject(1, _tblColPrefix + "_value");
			ps.setObject(2, _value);
			ps.setObject(3, _tblColPrefix + "_id");
			ps.setObject(4, _foreinId);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected String getIdCol() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected int getNoCols() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	protected String getTblname() {
		// TODO Auto-generated method stub
		return null;
	}

}
